﻿using System.ComponentModel;
using Microsoft.Practices.Prism.Commands;

namespace SlXnaApp1.ViewModel
{
    public class SettingsViewModel : INotifyPropertyChanged
    {
        private string _defaultUserName;
        public string DefaultUserName
        {
            get { return _defaultUserName; }
            set { _defaultUserName = value; RaisePropertyChanged("DefaultUserName"); }
        }

        public SettingsViewModel()
        {
            _saveNameCommand = new DelegateCommand(SaveName);
            _defaultUserName = Model.Settings.GetDefaultUserName();
        }

        private readonly DelegateCommand _saveNameCommand;
        public DelegateCommand SaveNameCommand
        {
            get
            {
                return _saveNameCommand;
            }
        }

        public void SaveName()
        {
            Model.Settings.SetDefaultUserName(DefaultUserName);
        }

        public void ResetToDefault()
        {
            Model.Settings.ToDefaultSettings();
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
